package com.hyfrogx.modules.manage.controller.userauth;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.common.utils.R;
import com.hyfrogx.common.validator.ValidatorUtils;
import com.hyfrogx.modules.manage.entity.userauth.HyUserAutherEntity;
import com.hyfrogx.modules.manage.form.userauth.AuthUpdateForm;
import com.hyfrogx.modules.manage.service.userauther.HyUserAutherService;
import com.hyfrogx.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Map;

/**
 * @author ：Li9527
 * @date ：Created in 2019-12-02 19:10
 * @description：直播认证管理控制类
 * @modified By：
 * @version: 1.0.0
 */

@RestController
@RequestMapping("/auther")
@Api(value = "HyUserAutherController", tags = {"后台--直播认证管理"})
public class HyUserAutherController extends AbstractController {

    @Autowired
    HyUserAutherService userAutherService;

    /**
     * 获取直播认证列表
     *
     * @param params
     * @return list
     */
    @GetMapping("/get")
    @ApiOperation("获取直播认证列表")
    public R getVipZoomlist(@RequestParam Map<String, Object> params) {
        params.put("isAsc", false);
        Page page = userAutherService.selectPageByConditions(new QueryExt(params));
        return R.ok().put("page", page);
    }

    /**
     * 审核认证信息
     *
     * @param
     * @return list
     */
    @PostMapping(value="edit")
    @ApiOperation("审核认证信息")
    public R edit(@RequestBody AuthUpdateForm form){
        ValidatorUtils.validateClientEntity(form);
        HyUserAutherEntity userAutherEntity = new HyUserAutherEntity();
        BeanUtils.copyProperties(form,userAutherEntity);
        userAutherEntity.setVerifyDate(new Date());
        userAutherEntity.setVerifyId(getUserId().intValue());
        Boolean result = userAutherService.updateById(userAutherEntity);
        if(result){
            return R.ok("审核成功");
        }else {
            return  R.error("审核失败");
        }

    }

}
